import { Login, MenuButton } from "@/api/types/base";
import { PORT1 } from "@/api/config/servicePort";
// import authButtonList from "@/assets/json/authButtonList.json";
import http from "@/api/services";

const apiUrl = {
  LOGIN: PORT1 + "/login",
  GET_MENU_LIST: PORT1 + "/getMenuList",
  LOGOUT: PORT1 + "/logout",
  GET_MENU_BUTTON_LIST: PORT1 + "/getMenuButtonList"
};

/**
 * @name 登录模块
 */
// 用户登录
export const loginApi = (params: Login.ReqLoginForm) => {
  return http.post<Login.ResLogin>(apiUrl.LOGIN, params, { loading: false });
};

// 获取菜单列表
export const getAuthMenuListApi = () => {
  return http.get<Menu.MenuOptions[]>(apiUrl.GET_MENU_LIST, {}, { loading: false });
};

// 获取按钮权限
export const getAuthButtonListApi = () => {
  return http.get<MenuButton[]>(apiUrl.GET_MENU_BUTTON_LIST, {}, { loading: false });
  // return http.get<Login.ResAuthButtons>(PORT1 + `/auth/buttons`, {}, { loading: false });
  // 如果想让按钮权限变为本地数据，注释上一行代码，并引入本地 authButtonList.json 数据
  // return authButtonList;
};

// 用户退出登录
export const logoutApi = () => {
  return http.get(apiUrl.LOGOUT);
};
